(self.webpackChunkmp_webgl = self.webpackChunkmp_webgl || []).push([
  [464],
  {
    22569: (t, e, a) => {
      "use strict";
      a.r(e),
        a.d(e, {
          SearchModeToggleCommand: () => o.X,
          SendQueryCommand: () => o.H,
          default: () => f,
        });
      var i,
        s = a(47724),
        n = a(40698),
        r = a(74371),
        h = a(38003),
        o = a(62644),
        c = a(4141);
      !(function (t) {
        (t[(t.Instant = 0)] = "Instant"),
          (t[(t.FadeToBlack = 1)] = "FadeToBlack"),
          (t[(t.Interpolate = 2)] = "Interpolate"),
          (t[(t.MoveToBlack = 3)] = "MoveToBlack");
      })(i || (i = {}));
      var l = a(29422),
        d = a(60225);
      class MattertagSearchResultItem {
        constructor(t, e) {
          (this.mattertag = t),
            (this.engine = e),
            (this.id = this.mattertag.sid),
            (this.title = this.mattertag.label),
            (this.description = this.mattertag.description),
            (this.type = c.B.MATTERTAG),
            (this.floorId = this.mattertag.floorId),
            (this.onSelect = () => {
              this.engine.commandBinder.issueCommand(
                new d.Y(this.mattertag.sid, i.Interpolate)
              );
            });
        }
        get color() {
          const t = this.mattertag.color;
          return `rgb(${255 * t.r}, ${255 * t.g}, ${255 * t.b})`;
        }
      }
      class LabelSearchResultItem {
        constructor(t, e) {
          (this.label = t),
            (this.engine = e),
            (this.id = this.label.sid),
            (this.title = this.label.text),
            (this.type = c.B.LABEL),
            (this.floorId = this.label.floorId),
            (this.onSelect = () => {
              this.engine.commandBinder.issueCommand(new l.Cs(this.label));
            });
        }
      }
      var m = a(79553),
        g = a(24151),
        u = a(92532),
        p = a(23953),
        w = a(27326);
      class SearchManager {
        constructor(t, e) {
          (this.engine = t),
            (this.initialized = !1),
            (this.searchText = ""),
            (this.initPromise = this.init(e));
        }
        async init(t) {
          const e = this.engine.market;
          return Promise.all([e.waitForData(w.c)]).then(([e]) => {
            (this.floorsViewData = e), t && this.updateSearchText(t);
          });
        }
        async activate() {
          this.initialized || ((this.initialized = !0), await this.initPromise),
            await this.engine.commandBinder.issueCommand(new o.X(!0));
        }
        async deactivate() {
          await this.engine.commandBinder.issueCommand(new o.X(!1));
        }
        updateSearchText(t) {
          this.searchText = t;
        }
        getSearchText() {
          return this.searchText;
        }
      }
      var D = a(33874),
        T = a(13789),
        y = a(8150),
        S = a(41591),
        b = a(69617),
        C = a(86010),
        M = a(21479),
        R = a(89046),
        B = a(88454);
      const { TOOLS: v } = T.Z;
      class SearchModule extends s.Y {
        constructor() {
          super(...arguments),
            (this.name = "search"),
            (this.query = ""),
            (this.searchResultsData = new b.r()),
            (this.activated = !1),
            (this.textParser = new C.v({ links: !0 })),
            (this.getPlainText = (t) => this.textParser.getPlainText(t)),
            (this.dataDirty = !1),
            (this.onApplicationChange = async () => {
              this.toolsData.getTool(m.w1.SEARCH) || this.registerTool();
            }),
            (this.updateItemList = async () => {
              const { dataMap: t, engine: e } = this,
                a = [];
              t.mattertagsData.iterate((t) =>
                a.push(new MattertagSearchResultItem(t, e))
              ),
                t.labelData.iterate((t) =>
                  a.push(new LabelSearchResultItem(t, e))
                ),
                (this.itemList = a),
                (this.dataDirty = !1);
            }),
            (this.toggleSearchMode = async (t) => {
              t.opened ? this.activateTool() : this.deactivateTool();
            }),
            (this.search = async (t) => {
              this.dataDirty && (await this.updateItemList());
              const e = t.query.toLowerCase(),
                a = this.itemList.filter((t) => {
                  const a = t.title,
                    i = t.description,
                    s =
                      a.toLowerCase().includes(e) ||
                      (!!i && this.getPlainText(i).toLowerCase().includes(e));
                  return (
                    t.type === c.B.MATTERTAG &&
                      this.pinRenderer.setPinVisible(t.id, s),
                    s
                  );
                });
              this.searchResultsData.setResults(a),
                this.searchResultsData.setQuery((this.query = t.query));
            });
        }
        async init(t, e) {
          let a;
          (this.config = t),
            (this.engine = e),
            (this.config = t),
            this.registerTool(),
            await this.updateDataMap(),
            ([this.settingsData, this.toolsData, a, this.appData] =
              await Promise.all([
                e.market.waitForData(D.e),
                e.market.waitForData(g.t),
                e.getModule(S.default),
                e.market.waitForData(M.pu),
              ])),
            (this.pinRenderer = a.pinRenderer);
          const i = () => (this.dataDirty = !0);
          this.bindings.push(
            e.commandBinder.addBinding(o.X, this.toggleSearchMode),
            e.commandBinder.addBinding(o.H, this.search),
            this.settingsData.onChanged(i),
            ...Object.values(this.dataMap).map((t) => t.onChanged(i)),
            e.subscribe(y.bS, this.onApplicationChange)
          ),
            e.market.register(this, b.r, this.searchResultsData),
            t.urlSearch &&
              this.engine.commandBinder.issueCommand(new u.tT(m.w1.SEARCH, !0));
        }
        registerTool() {
          const { config: t } = this,
            e = new p.U({
              id: m.w1.SEARCH,
              namePhraseKey: v.SEARCH,
              drawer: !1,
              panel: !0,
              icon: "icon-magnifying-glass",
              analytic: "search_mode",
              toolbar: !1,
              dimmed: !1,
              enabled: !0,
              manager: new SearchManager(
                this.engine,
                t.urlSearch ? decodeURIComponent(t.urlSearch) : void 0
              ),
            });
          this.engine.commandBinder.issueCommand(new u.MV([e]));
        }
        async updateDataMap() {
          const { engine: t } = this,
            [e, a, i] = await Promise.all([
              t.market.waitForData(n.n),
              t.market.waitForData(r.D),
              t.market.waitForData(h.X),
            ]);
          this.dataMap = {
            mattertagsData: e,
            labelData: a,
            measurementModeData: i,
          };
        }
        activateTool() {
          this.activated ||
            (this.config.workshop &&
              (this.appData.application === M.Mx.WORKSHOP &&
                this.engine.commandBinder.issueCommand(new R.Mn(!1)),
              this.engine.commandBinder.issueCommand(new B.KW(!1))),
            (this.activated = !0),
            this.searchResultsData.setQuery(this.query));
        }
        deactivateTool() {
          this.activated &&
            (this.config.workshop &&
              (this.appData.application === M.Mx.WORKSHOP &&
                this.engine.commandBinder.issueCommand(new R.Mn(!0)),
              this.engine.commandBinder.issueCommand(new B.KW(!0))),
            (this.activated = !1),
            this.searchResultsData.setQuery(null),
            this.resetAllVisibility());
        }
        resetAllVisibility() {
          this.itemList
            .filter((t) => t.type === c.B.MATTERTAG)
            .forEach((t) => this.pinRenderer.setPinVisible(t.id, !0));
        }
      }
      const f = SearchModule;
    },
  },
]);
